﻿<UserControl x:Class="WpfFeeCalculator.View.CalculationView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ssg="clr-namespace:SpreadsheetGear.Windows.Forms;assembly=SpreadsheetGear"
             xmlns:src="clr-namespace:WpfFeeCalculator.Converters"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Resources\ComboboxResource.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="65"/>
            <ColumnDefinition Width="60"/>
            <ColumnDefinition/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="4"/>
            <RowDefinition />
            <RowDefinition Height="4"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.Resources>
            <src:ImageConverter x:Key="imageConverter"/>
            

            <Style x:Key="BaseListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <Grid Background="Transparent">
                                <Image ToolTip="{Binding}" HorizontalAlignment="Left" Height="22" Width="22" Source="{Binding Converter={StaticResource ResourceKey=imageConverter}}"></Image>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="ListBox">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0" Background="Transparent"/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </Grid.Resources>
        <TextBlock  Grid.Column="0" Grid.Row="0" Margin="2" Text="Portfolio"/>
        <ComboBox Grid.Column="1" Grid.Row="0" Grid.ColumnSpan =" 3" 
                  x:Name="PortfolioTypeCmb" 
                  
                  Loaded="ComboBox_Loaded"
                  ItemsSource="{Binding Path=PortfolioNames, Mode=OneWay}"
                  SelectedItem="{Binding Path=PortfoloName}"
                  
                  
                  
                  Validation.ErrorTemplate="{x:Null}">
            
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                            <TextBlock Text="{Binding Path=Name}" />
                        <ListBox x:Name="CompartmentsListBox" ItemsSource="{Binding Path=Currencies}"
             ItemContainerStyle="{StaticResource BaseListBoxItemStyle}"
             VerticalAlignment="Top" 
                                 Background="Transparent"/>
                       
                        
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>

        </ComboBox>
            <TextBlock  Grid.Column="0" Grid.Row="1" Margin="2" Text="Date"/>
        <DatePicker  Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="3" SelectedDate="{Binding Path=AsOfDate, Mode=TwoWay}"></DatePicker>
        <Button Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Margin="1,1,1,1" Command="{Binding Path=LoadPriceCutOffCommand}">Load PriceCutOff</Button>
        <ComboBox  Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2" 
                   x:Name="priceCutOffCmb" 
                   Loaded="PriceCutOffComboBox_Loaded"
                   ItemsSource="{Binding Path=GetPriceCutOffCompleted}"
                   SelectedItem="{Binding Path=CurrentPriceCutOff}">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding Path=Label}"/>
                        <TextBlock Text="{Binding Path=ValueAsOf}"/>
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

            <WindowsFormsHost Grid.Row="4" Grid.ColumnSpan="4" Name="wfHost">
            <ssg:WorkbookView  Name="calculationWorkbookView"></ssg:WorkbookView>
        </WindowsFormsHost>
        <GridSplitter ResizeDirection="Rows"   Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="5" Width="Auto" Height="3" 
            HorizontalAlignment="Stretch" 
            VerticalAlignment="Stretch" 
            Margin="0"/>



        <DataGrid x:Name="InformationDG" Grid.Row="6" Grid.ColumnSpan="4" ItemsSource="{Binding Path=Information}" IsSynchronizedWithCurrentItem="True">
            
            <DataGrid.InputBindings>
                <MouseBinding
            MouseAction="LeftDoubleClick"
            Command="{Binding DoubleClickCommand}"
            CommandParameter="{Binding Information/}"/>
            </DataGrid.InputBindings>


        </DataGrid>
        <StackPanel Orientation="Horizontal" Grid.Row="7" Grid.ColumnSpan="4" HorizontalAlignment="Right">
            <StackPanel.Resources>
                <BooleanToVisibilityConverter x:Key="BoolToVis"/>
            </StackPanel.Resources>
            <Button   Margin="2" Command="{Binding Path=LoadCalculationCommand}" MinWidth="60">Load</Button>
            <Button   Margin="2" MinWidth="50" Command="{Binding Path=DisplayExcelDataCommand}">Display Excel</Button>
        </StackPanel>
    </Grid>
    <!--Visibility="{Binding Path=UploadExcelCompleted.IsCompleted, Converter={StaticResource BoolToVis}-->
</UserControl>
